<template>
  <div class="app-container">
    <el-form
      :model="queryParams"
      ref="queryForm"
      size="small"
      :inline="true"
      v-show="showSearch"
      label-width="68px"
    >
      <el-form-item label="姓名" prop="xingMing" label-width="300">
        <el-input
          v-model="queryParams.xingMing"
          placeholder="请输入姓名"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="性别" prop="xingBie">
        <el-select v-model="queryParams.xingBie" placeholder="请输入性别">
          <el-option
            v-for="dict in dict.type.sys_user_xb"
            :key="dict.value"
            :label="dict.label"
            :value="dict.value"
          ></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="部门" prop="departID">
        

        <el-select
              v-model="queryParams.departID"
              placeholder="请选择部门" @change="selectChange" style="width:100%"
            >
              <el-option v-for="item in deptlist" :key="item.deptId" :value="item.deptId" :label="item.deptName"/>
            </el-select>
     
      </el-form-item>

      <el-form-item>
        <el-button
          type="primary"
          icon="el-icon-search"
          size="mini"
          @click="handleQuery"
          >搜索</el-button
        >
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery"
          >重置</el-button
        >
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button
          type="primary"
          plain
          icon="el-icon-plus"
          size="mini"
          @click="handleAdd"
          v-hasPermi="['hrmanagement:zrsglryda:add']"
          >新增</el-button
        >
      </el-col>
      <!-- <el-col :span="1.5">
        <el-button
          type="success"
          plain
          icon="el-icon-edit"
          size="mini"
          :disabled="single"
          @click="handleUpdate"
          v-hasPermi="['hrmanagement:zrsglryda:edit']"
          >详情设置 </el-button
        >
      </el-col> -->
      <el-col :span="1.5">
        <el-button
          type="danger"
          plain
          icon="el-icon-delete"
          size="mini"
          :disabled="multiple"
          @click="handleDelete"
          v-hasPermi="['hrmanagement:zrsglryda:remove']"
          >删除</el-button
        >
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="warning"
          plain
          icon="el-icon-download"
          size="mini"
          @click="handleExport"
          v-hasPermi="['hrmanagement:zrsglryda:export']"
          >导出</el-button
        >
      </el-col>
      <right-toolbar
        :showSearch.sync="showSearch"
        @queryTable="getList"
      ></right-toolbar>
    </el-row>

    <el-table
      v-loading="loading"
      :data="zrsglrydaList"
      @selection-change="handleSelectionChange"
    >
      <el-table-column type="selection" width="55" align="center" />
      <el-table-column label="员工号" align="center" prop="yuanGongHao" />
      <el-table-column label="姓名" align="center" prop="xingMing" />

      <el-table-column label="部门名称" align="center" prop="departName" />
      <el-table-column label="身份证号" align="center" prop="shenFenZhengHao"  width="200"/>
      <el-table-column
        label="参加工作时间"
        align="center"
        prop="canJiaGongZuoShiJian"
        width="180"
      >
        <template slot-scope="scope">
          <span>{{
            parseTime(scope.row.canJiaGongZuoShiJian, "{y}-{m}-{d}")
          }}</span>
        </template>
      </el-table-column>

      <el-table-column label="性别" align="center" prop="xingBie" />
      <el-table-column label="民族" align="center" prop="minZu" />
      <el-table-column label="政治面貌" align="center" prop="zhengZhiMianMao" />
      <el-table-column
        label="操作"
        align="center"
        class-name="small-padding fixed-width"
        fixed="right"
        min-width="120"
      >
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="handleUpdate(scope.row)"
            v-hasPermi="['hrmanagement:zrsglryda:edit']"
            >详情设置</el-button
          >
          <el-button
            size="mini"
            type="text"
            icon="el-icon-delete"
            @click="handleDelete(scope.row)"
            v-hasPermi="['hrmanagement:zrsglryda:remove']"
            >删除</el-button
          >
        </template>
      </el-table-column>
    </el-table>

    <pagination
      v-show="total > 0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />

    <!-- 添加或修改hrmanagement对话框 -->
    <el-dialog
      :title="title"
      :visible.sync="open"
      width="1200px"
      append-to-body
    >
      <el-form ref="form" :model="form" :rules="rules" label-width="80px">
        <el-card class="box-card">
          <div slot="header" class="clearfix">
            <span>个人信息</span>
          </div>
          <el-row>
            <el-col :span="12">
              <el-form-item
                label="员工号"
                label-width="130px"
                pprop="yuanGongHao"
              >
                <el-input
          disabled
                  v-model="form.yuanGongHao"
                  placeholder="请输入员工号"
                />
              </el-form-item>
            </el-col>

            <el-col :span="12">
              <el-form-item label="姓名" label-width="130px" prop="xingMing">
                <el-input v-model="form.xingMing" placeholder="请输入姓名"     disabled/>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item
                label="曾用名"
                label-width="130px"
                prop="cengYongMing"
             
              >
                <el-input
                
                  v-model="form.cengYongMing"
                  placeholder="请输入曾用名"
                />
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item
                label="出生日期"
                label-width="130px"
                prop="chuShengRiQi"
              >
                <el-date-picker
                  clearable
                  v-model="form.chuShengRiQi"
                  type="date"
                  value-format="yyyy-MM-dd"
                  placeholder="请选择出生日期"
                >
                </el-date-picker>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="周岁" label-width="130px" prop="zhouSui">
                <el-input
                type="number"
                  v-model="form.zhouSui"
                  placeholder="请输入周岁"
                >
                <span slot="suffix">岁</span>
              </el-input>
               
              </el-form-item>
            </el-col>

            <el-col :span="12">
              <el-form-item
                label="身份证号"
                label-width="130px"
                prop="shenFenZhengHao"
              >
                <el-input
                  v-model="form.shenFenZhengHao"
                  placeholder="请输入身份证号"
                />
              </el-form-item>
            </el-col>

            <el-col :span="12">
              <el-form-item
                label="参加工作时间"
                label-width="130px"
                prop="canJiaGongZuoShiJian"
              >
                <el-date-picker
                  clearable
                  v-model="form.canJiaGongZuoShiJian"
                  type="date"
                  value-format="yyyy-MM-dd"
                  placeholder="请选择参加工作时间"
                >
                </el-date-picker>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="性别" label-width="130px" prop="xingBie">
                <el-select v-model="form.xingBie" placeholder="请输入性别">
                  <el-option
                    v-for="dict in dict.type.sys_user_xb"
                    :key="dict.value"
                    :label="dict.label"
                    :value="dict.value"
                  ></el-option>
                </el-select>
              </el-form-item>
            </el-col>

            <el-col :span="12">
              <el-form-item label="民族" label-width="130px" prop="minZu">
                <el-input v-model="form.minZu" placeholder="请输入民族" />
              </el-form-item>
            </el-col>

            <el-col :span="12">
              <el-form-item
                label="政治面貌"
                label-width="130px"
                prop="zhengZhiMianMao"
              >
                <el-select
                  v-model="form.zhengZhiMianMao"
                  placeholder="请输入性别"
                >
                  <el-option
                    v-for="dict in dict.type.sys_user_zzmm"
                    :key="dict.value"
                    :label="dict.label"
                    :value="dict.value"
                    placeholder="请选择政治面貌"
                  ></el-option>
                </el-select>
              </el-form-item>
            </el-col>

            <el-col :span="12">
              <el-form-item
                label="婚姻状况"
                label-width="130px"
                prop="hunYinZhuangKuang"
              >
                <el-select
                  v-model="form.hunYinZhuangKuang"
                  placeholder="请输入婚姻状况"
                >
                  <el-option
                    v-for="dict in dict.type.sys_user_hyzk"
                    :key="dict.value"
                    :label="dict.label"
                    :value="dict.value"
                    placeholder="请选择婚姻状况"
                  ></el-option>
                </el-select>
              </el-form-item>
            </el-col>

            <el-col :span="12">
              <el-form-item label="籍贯" label-width="130px" prop="jiGuan">
                <el-cascader
                  size="large"
                  :options="options"
                  v-model="form.jiGuan"
                  placeholder="请选择籍贯"
                >
                </el-cascader>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item
                label="家庭住址"
                label-width="130px"
                prop="jiaTingZhuZhi"
              >
                <el-input
                  v-model="form.jiaTingZhuZhi"
                  placeholder="请输入家庭住址"
                />
              </el-form-item>
            </el-col>

            <el-col :span="12">
              <el-form-item
                label="员工性质"
                label-width="130px"
                prop="yuanGongXingZhi"
              >
                <el-select
                  v-model="form.yuanGongXingZhi"
                  placeholder="请选择员工性质"
                >
                  <el-option
                    v-for="dict in dict.type.sys_user_ygxz"
                    :key="dict.value"
                    :label="dict.label"
                    :value="dict.value"
                    placeholder="请选择员工性质"
                  ></el-option>
                </el-select>
              </el-form-item>
            </el-col>
          </el-row>
        </el-card>

        <el-card class="box-card">
          <div slot="header" class="clearfix">
            <span>单位信息</span>
          </div>
          <el-row>
            <!-- <el-col :span="12">
              <el-form-item label="公司" label-width="130px" prop="companyID">
                <treeselect
                  v-model="form.companyID"
                  :options="deptOptions"
                  :show-count="true"
                  placeholder="请选择归属公司"
                />
              </el-form-item>
            </el-col> -->
            <el-col :span="12">
              <el-form-item
                label="员工状态"
                label-width="130px"
                prop="yuanGongZhuangTai"
              >
                <el-select
                  v-model="form.yuanGongZhuangTai"
                  placeholder="请输入员工状态"
                >
                  <el-option
                    v-for="dict in dict.type.sys_user_ygzt"
                    :key="dict.value"
                    :label="dict.label"
                    :value="dict.value"
                    placeholder="请选择员工性质"
                  ></el-option>
                </el-select>
              </el-form-item>
            </el-col>
           
           
            <el-col :span="12">
              <el-form-item label="部门" label-width="130px" prop="departID">
                <treeselect
                  v-model="form.departID"
                  :options="deptOptions"
                  :show-count="true"
                  placeholder="请选择归属部门"
                />
              </el-form-item>
            </el-col>

            <el-col :span="12">
              <el-form-item
                label="入职时间"
                label-width="130px"
                prop="ruZhiShiJian"
              >
                <el-date-picker
                  clearable
                  v-model="form.ruZhiShiJian"
                  type="date"
                  value-format="yyyy-MM-dd"
                  placeholder="请选择入职时间"
                >
                </el-date-picker>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="岗位" label-width="130px" prop="gangWei">


              <!-- <el-select v-model="form.gangWei" multiple placeholder="请选择岗位">
                <el-option
                  v-for="item in postOptions"
                  :key="item.postId"
                  :label="item.postName"
                  :value="item.postId"
                  :disabled="item.status == 1"
                ></el-option>
              </el-select> -->

              <el-input
                  v-model="form.gangWei"
                  placeholder="请输入岗位"
                />

              </el-form-item>
            </el-col>
           
            <el-col :span="12">
              <el-form-item label="职称" label-width="130px" prop="zhiCheng">
                <el-input v-model="form.zhiCheng" placeholder="请输入职称" />
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item
                label="入职方式"
                label-width="130px"
                prop="ruZhiFangShi"
              >
                <el-select
                  v-model="form.ruZhiFangShi"
                  placeholder="请输入入职方式"
                >
                  <el-option
                    v-for="dict in dict.type.sys_user_rzfs"
                    :key="dict.value"
                    :label="dict.label"
                    :value="dict.value"
                    placeholder="请选择员工性质"
                  ></el-option>
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item
                label="合同类型"
                label-width="130px"
                prop="heTongLeiXing"
              >
                <el-select
                  v-model="form.heTongLeiXing"
                  placeholder="请输入合同类型"
                >
                  <el-option
                    v-for="dict in dict.type.sys_user_htlx"
                    :key="dict.value"
                    :label="dict.label"
                    :value="dict.value"
                    placeholder="请输入合同类型"
                  ></el-option>
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item
                label="试用期限"
                label-width="130px"
                prop="shiYongQiXian"
              >


              <el-select
                  v-model="form.shiYongQiXian"
                  placeholder="请选择试用期限"
                >
                  <el-option
                    v-for="dict in dict.type.hrm_doc_syqx"
                    :key="dict.value"
                    :label="dict.label"
                    :value="dict.value"
                    placeholder="请选择试用期限"
                  ></el-option>
                </el-select>

              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item
                label="试用期薪酬"
                label-width="130px"
                prop="shiYongQiXinChou"
              >
                <el-input
                type="number"
                  v-model="form.shiYongQiXinChou"
                  placeholder="请输入试用期薪酬"
                >
                <span slot="suffix">元</span>
              </el-input>
              </el-form-item>
            </el-col>

            <el-col :span="12">
              <el-form-item label="年薪" label-width="130px" prop="nianXin">
                <el-input  type="number" v-model="form.nianXin" placeholder="请输入年薪">
                  <span slot="suffix">万元</span>
                </el-input>
              </el-form-item>
            </el-col>
          </el-row>
        </el-card>

        <el-card class="box-card">
          <div slot="header" class="clearfix">
            <span>学历信息</span>
          </div>
          <el-row>
            <el-col :span="12">
              <el-form-item
                label="全日制学历"
                label-width="130px"
                prop="quanRiZhiXueLi"
              >
                <el-select
                  v-model="form.quanRiZhiXueLi"
                  placeholder="请输入全日制学历"
                >
                  <el-option
                    v-for="dict in dict.type.sys_user_qrzxl"
                    :key="dict.value"
                    :label="dict.label"
                    :value="dict.value"
                    placeholder="请输入合同类型"
                  ></el-option>
                </el-select>
              </el-form-item>
            </el-col>

            <el-col :span="12">
              <el-form-item
                label="全日制学历证编号"
                label-width="130px"
                prop="quanRiZhiXueLiZhengBianHao"
              >
                <el-input
                  v-model="form.quanRiZhiXueLiZhengBianHao"
                  placeholder="请输入全日制学历证编号"
                />
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item
                label="全日制学位"
                label-width="130px"
                prop="quanRiZhiXueWei"
              >
                <el-select
                  v-model="form.quanRiZhiXueWei"
                  placeholder="请输入全日制学历"
                >
                  <el-option
                    v-for="dict in dict.type.sys_user_xw"
                    :key="dict.value"
                    :label="dict.label"
                    :value="dict.value"
                    placeholder="请输入合同类型"
                  ></el-option>
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item
                label="全日制学位证编号"
                label-width="130px"
                pprop="quanRiZhiXueWeiZhengBianHao"
              >
                <el-input
                  v-model="form.quanRiZhiXueWeiZhengBianHao"
                  placeholder="请输入全日制学位证编号"
                />
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item
                label="全日制毕业时间"
                label-width="130px"
                prop="quanRiZhiBiYeShiJian"
              >
                <el-date-picker
                  clearable
                  v-model="form.quanRiZhiBiYeShiJian"
                  type="date"
                  value-format="yyyy-MM-dd"
                  placeholder="请选择全日制毕业时间"
                >
                </el-date-picker>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item
                label="全日制毕业院校"
                label-width="130px"
                pprop="quanRiZhiBiYeYuanXiao"
              >
                <el-input
                  v-model="form.quanRiZhiBiYeYuanXiao"
                  placeholder="请输入全日制毕业院校"
                />
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item
                label="全日制专业"
                label-width="130px"
                prop="quanRiZhiZhuanYe"
              >
                <el-input
                  v-model="form.quanRiZhiZhuanYe"
                  placeholder="请输入全日制专业"
                />
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item
                label="是否最高学历"
                label-width="130px"
                prop="shiFouZuiGaoXueLi"
              >
                <el-radio-group v-model="form.shiFouZuiGaoXueLi">
                  <el-radio label="是">是</el-radio>
                  <el-radio label="否">否</el-radio>
                </el-radio-group>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item
                label="最高学历"
                label-width="130px"
                prop="zuiGaoXueLi"
              >
                <el-select
                  v-model="form.zuiGaoXueLi"
                  placeholder="请输入最高学历"
                >
                  <el-option
                    v-for="dict in dict.type.sys_user_qrzxl"
                    :key="dict.value"
                    :label="dict.label"
                    :value="dict.value"
                    placeholder="请输入合同类型"
                  ></el-option>
                </el-select>
              </el-form-item>
            </el-col>

            <el-col :span="12">
              <el-form-item
                label="最高学历证编号"
                label-width="130px"
                prop="zuiGaoXueLiZhengBianHao"
              >
                <el-input
                  v-model="form.zuiGaoXueLiZhengBianHao"
                  placeholder="请输入最高学历证编号"
                />
              </el-form-item>
            </el-col>

            <el-col :span="12">
              <el-form-item
                label="最高学位"
                label-width="130px"
                prop="zuiGaoXueWei"
              >
                <el-select
                  v-model="form.zuiGaoXueWei"
                  placeholder="请输入最高学位"
                >
                  <el-option
                    v-for="dict in dict.type.sys_user_xw"
                    :key="dict.value"
                    :label="dict.label"
                    :value="dict.value"
                    placeholder="请输入最高学位"
                  ></el-option>
                </el-select>
              </el-form-item>
            </el-col>

            <el-col :span="12">
              <el-form-item
                label="最高学位证编号"
                label-width="130px"
                prop="zuiGaoXueWeiZhengBianHao"
              >
                <el-input
                  v-model="form.zuiGaoXueWeiZhengBianHao"
                  placeholder="请输入最高学位证编号"
                />
              </el-form-item>
            </el-col>

            <el-col :span="12">
              <el-form-item
                label="最高学历毕业时间"
                label-width="130px"
                prop="zuiGaoXueLiBiYeShiJian"
              >
                <el-date-picker
                  clearable
                  v-model="form.zuiGaoXueLiBiYeShiJian"
                  type="date"
                  value-format="yyyy-MM-dd"
                  placeholder="请选择最高学历毕业时间"
                >
                </el-date-picker>
              </el-form-item>
            </el-col>

            <el-col :span="12">
              <el-form-item
                label="最高学历毕业院校"
                label-width="130px"
                prop="zuiGaoXueLiBiYeYuanXiao"
              >
                <el-input
                  v-model="form.zuiGaoXueLiBiYeYuanXiao"
                  placeholder="请输入最高学历毕业院校"
                />
              </el-form-item>
            </el-col>

            <el-col :span="12">
              <el-form-item
                label="最高学历专业"
                label-width="130px"
                prop="zuiGaoXueLiZhuanYe"
              >
                <el-input
                  v-model="form.zuiGaoXueLiZhuanYe"
                  placeholder="请输入最高学历专业"
                />
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item
                label="最高学历学习方式"
                label-width="130px"
                prop="zuiGaoXueLiXueXiFangShi"
              >
                <el-select
                  v-model="form.zuiGaoXueLiXueXiFangShi"
                  placeholder="请输入最高学历学习方式"
                >
                  <el-option
                    v-for="dict in dict.type.sys_user_zgxlxxfs"
                    :key="dict.value"
                    :label="dict.label"
                    :value="dict.value"
                    placeholder="请输入合同类型"
                  ></el-option>
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item
                label="附件上传"
                label-width="130px"
                prop="zuiGaoXueLiXueXiFangShi"
              >
                <el-upload
                  ref="upload"
                  :limit="10"
                  :action="upload.url"
                  :headers="upload.headers"
                  :file-list="upload.fileList"
                  :on-progress="handleFileUploadProgress"
                   :on-success="handleFileSuccess"
                  :auto-upload="true"
                  :on-preview="handlePreview"
                  :on-remove="handleRemove"
                 :before-remove="beforeRemove"
                >
                  <el-button slot="trigger" size="small" type="primary"
                    >选取文件</el-button
                  >

                </el-upload>

              </el-form-item>
            </el-col>
          </el-row>
        </el-card>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import { deptTreeSelect ,getUser} from "@/api/system/user";
import { getToken } from "@/utils/auth";

import {
  listZrsglryda,
  getZrsglryda,
  delZrsglryda,
  addZrsglryda,
  updateZrsglryda,
 
} from "@/api/hrmanagement/zrsglryda";
import {getfilelist} from "@/api/system/info";
import { selectAllUser } from "@/api/system/user";
import { mapState } from 'vuex'
import { regionData } from "element-china-area-data";
import Treeselect from "@riophae/vue-treeselect";
import "@riophae/vue-treeselect/dist/vue-treeselect.css";
import loginVue from '../login.vue';
import { AllDept } from "@/api/system/dept";

export default {
  dicts: [
    "sys_user_zzmm",
    "sys_user_xb",
    "sys_user_hyzk",
    "sys_user_ygxz",
    "sys_user_ygzt",
    "sys_user_rzfs",
    "sys_user_htlx",
    "sys_user_qrzxl",
    "sys_user_xw",
    "sys_user_zgxlxxfs",
    "hrm_doc_syqx"

  ],
  name: "Zrsglryda",
  components: { Treeselect },
  computed: {
    ...mapState({
      nickName: state => state.user.nickname,
      userId: state => state.user.id,
deptId:state => state.user.deptId,
phonenumber:state => state.user.phonenumber,
postIds :state => state.user.postIds,

    
    }),
    
  },
  data() {
    return {
      upload: {
        isUploading: false,
        headers: { Authorization: "Bearer " + getToken() },
        url: process.env.VUE_APP_BASE_API + "/common/upload",
        fileList: [],
      },
      deptlist:[],

      postOptions: [],
      // 角色选项
      deptOptions: undefined,
      options: regionData,
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      zrsglrydaList: [],
      title: "",

      open: false,
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        xingMing: null,
        xingBie: null,
      },
      form: {},
      
      rules: {
        chuShengRiQi: [
          { required: true, message: "出生日期不能为空", trigger: "blur" },
         
        ],
        zhouSui: [
            { required: true, message: '请选择周岁', trigger: 'change' }
          ],
          shenFenZhengHao: [
            { required: true, message: '请输入身份证号', trigger: 'blur' },
          ],
          canJiaGongZuoShiJian: [
            { required: true, message: '请输入参加工作时间', trigger: 'blur' },
          ],
          xingBie: [
            { required: true, message: '请输入性别', trigger: 'blur' },
          ]
          ,
          yuanGongZhuangTai: [
            { required: true, message: '请输入员工状态', trigger: 'blur' },
          ],
          departID: [
            { required: true, message: '请输入部门', trigger: 'blur' },
          ],
        
          ruZhiShiJian: [
            { required: true, message: '请输入职时间', trigger: 'blur' },
          ],
          departID: [
            { required: true, message: '请输入部门', trigger: 'blur' },
          ],
        
          ruZhiShiJian: [
            { required: true, message: '请输入职时间', trigger: 'blur' },
          ],
          
      }
    };
  },
  created() {
    AllDept().then(response => {
          if (response.code === 200) {
            this.deptlist= response.data
          } else {
            this.$message.error(response.message)
          }
        })
    selectAllUser().then(response => {
this.alluserselect = response.data

      });
      
    this.getList();
    this.getDeptTree();
  },
  methods: {
    getDeptTree() {
      deptTreeSelect().then((response) => {
        this.deptOptions = response.data;
      });
    },
    getList() {
      this.loading = true;
      listZrsglryda(this.queryParams).then((response) => {
        this.zrsglrydaList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    cancel() {
      this.open = false;
      this.reset();
    },
    reset() {
      this.form = {
        id: null,
        status: null,
        companyID: null,
        companyName: null,
        departID: null,
        departName: null,
        xingMing: null,
        shenFenZhengHao: null,
        cengYongMing: null,
        canJiaGongZuoShiJian: null,
        chuShengRiQi: null,
        xingBie: null,
        minZu: null,
        zhengZhiMianMao: null,
        hunYinZhuangKuang: null,
        shouJiHaoMa: null,
        jiGuan: null,
        jiaTingZhuZhi: null,
        danWei: null,
        danweiTxt: null,
        buMen: null,
        bumenTxt: null,
        gangWei: null,
        ruZhiShiJian: null,
        yuanGongZhuangTai: null,
        zhiCheng: null,
        ruZhiFangShi: null,
        heTongLeiXing: null,
        shiYongQiXian: null,
        shiYongQiXinChou: null,
        nianXin: null,
        quanRiZhiXueLi: null,
        quanRiZhiXueLiZhengBianHao: null,
        quanRiZhiXueWei: null,
        quanRiZhiXueWeiZhengBianHao: null,
        quanRiZhiBiYeShiJian: null,
        quanRiZhiBiYeYuanXiao: null,
        quanRiZhiZhuanYe: null,
        shiFouZuiGaoXueLi: null,
        zuiGaoXueLi: null,
        zuiGaoXueLiZhengBianHao: null,
        zuiGaoXueWei: null,
        zuiGaoXueWeiZhengBianHao: null,
        zuiGaoXueLiBiYeShiJian: null,
        zuiGaoXueLiBiYeYuanXiao: null,
        zuiGaoXueLiZhuanYe: null,
        zuiGaoXueLiXueXiFangShi: null,
        yuanGongHao: null,
        yuanGongXingZhi: null,
        zhouSui: null,
        createBy: null,
        createTime: null,
        updateBy: null,
        updateTime: null,
      };

      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map((item) => item.id);
      this.single = selection.length !== 1;
      this.multiple = !selection.length;
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.reset();
      this.upload.fileList=[]
      this.open = true;
      this.title = "添加人员档案";

      this.form.yuanGongHao=this.userId,
      this.form.xingMing=this.nickName
      this.form.departID=this.deptId
      this.form.shouJiHaoMa=this.phonenumber


    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.reset();
      const id = row.id || this.ids;
      getZrsglryda(id).then((response) => {
        this.form = response.data;
        if (this.form.jiGuan) {
          this.form.jiGuan = this.form.jiGuan.split(","); 
        }
        this.open = true;
        this.title = "修改人员档案";
      });
      getfilelist(id,"OaZrsglryda").then((response) => {
      this.upload.fileList = response.data
      });
    },
    /** 提交按钮 */
    submitForm() {
      if (this.form.jiGuan !== null) {
        this.form.jiGuan = this.form.jiGuan.join(",");
      }
var commonDto = {
  form:this.form,
  Extra: JSON.stringify(this.upload.fileList)

}

    
      this.$refs["form"].validate((valid) => {
        if (valid) {
          if (this.form.id != null) {
            updateZrsglryda(commonDto).then((response) => {
              this.$modal.msgSuccess("修改成功");
              this.open = false;
              this.getList();
            });
          } else {
            addZrsglryda(commonDto).then((response) => {
              this.$modal.msgSuccess("新增成功");
              this.open = false;
              this.getList();
            });
          }
        }
      });
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const ids = row.id || this.ids;
      this.$modal
        .confirm('是否确认删除hrmanagement编号为"' + ids + '"的数据项？')
        .then(function () {
          return delZrsglryda(ids);
        })
        .then(() => {
          this.getList();
          this.$modal.msgSuccess("删除成功");
        })
        .catch(() => {});
    },
    /** 导出按钮操作 */
    handleExport() {
      this.download(
        "hrmanagement/zrsglryda/export",
        {
          ...this.queryParams,
        },
        `zrsglryda_${new Date().getTime()}.xlsx`
      );
    },
    handleRemove(file, fileList) {
      console.log(file, fileList);
    },
    handlePreview(file) {

      console.log("file");
 
      
 window.location.href ="http://localhost:8085"+file.filePath

                // http://localhost:8085/profile/upload/2024/02/02/%E5%BE%AE%E4%BF%A1%E6%88%AA%E5%9B%BE_20240131162314_20240202133841A002.png
      // window.location.href ="http://localhost:8085"+process.env.VUE_APP_BASE_API + "/common/download/resource?fileName=" +file.filePath
 console.log(file);
    },
    handleExceed(files, fileList) {
      this.$message.warning(
        `当前限制选择 3 个文件，本次选择了 ${files.length} 个文件，共选择了 ${
          files.length + fileList.length
        } 个文件`
      );
    },
    beforeRemove(file, fileList) {
      return this.$confirm(`确定移除 ${file.name}？`);
    },
     // 文件上传中处理
     handleFileUploadProgress(event, file, fileList) {
      this.upload.isUploading = true;
    },
    // 文件上传成功处理
    handleFileSuccess(response, file, fileList) {
      

      if (response.code === 200) {
        this.upload.fileList.push({name: response.originalFilename ,filePath:response.filePath});


      } 
    },
    beforeRemove(file, fileList) {
        return this.$confirm(`确定移除 ${ file.name }？`);
      },
      handleRemove(file, fileList) {
        console.log("this.upload.fileList");
        this.upload.fileList = this.upload.fileList.filter(item => item.filePath !== file.filePath);
        console.log(this.upload.fileList);
   



      },
  },
 
};
</script>
